<?php
namespace app\admin\model;
use think\Model;
use think\Db;

/**
 * 新短信签名
 * @package app\admin\model
 */
class BusSmsSign extends Model
{
    public static function getList($request)
    {
        $where = [];
        if(!empty($request['sign'])) {
            $where[]  = ['sms_sign','like', '%' . $request['sign'] . '%'];
        }

        if(isset($request['onoff']) && $request['onoff'] != '') {
            $where[]  = ['onoff','eq', $request['onoff']];
        }
        return self::where($where)->paginate($request['limit'], false,['query' => $request])
                            ->each(function($item, $key){
                                switch ($item->onoff) {
                                    case '1':
                                        $item->onoff = '<span class="layui-badge layui-bg-green">已开启</span>';
                                        break;
                                    case '0':
                                        $item->onoff = '<span class="layui-badge layui-bg-orange">已禁用</span>';
                                        break;

                                    default:
                                        # code...
                                        break;
                                }
                            });
    }

    public static function add($data)
    {
        return self::create($data);
    }
}